package com.bt.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bt.mapper.DtsCollectMapper;
import com.bt.pojo.DtsCollect;
import com.bt.service.DtsCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wbt
 * @version v1.0
 * @project shop_manage
 * @data 2022/9/24 19:01
 **/
@Service
public class DtsCollectServiceImpl implements DtsCollectService {
    @Autowired
    private DtsCollectMapper dtsCollectMapper;
    @Override
    public IPage<DtsCollect> findCollectByPage(Integer page, Integer limit, Integer userId, Integer valueId, String sort, String order) {
        return dtsCollectMapper.selectPage(new Page<>(page,limit),new QueryWrapper<DtsCollect>().eq(userId!=null?true:false,"user_id",userId).eq(valueId!=null?true:false,"value_id",valueId).orderBy(!StringUtils.isEmpty(sort),"asc".equalsIgnoreCase(order),sort) );
    }
}
